package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.iview.InitView
import hlhj.fhp.checkpoint.javaBean.MEBean

/**
 * Created by Never Fear   on 2018\11\13 0013.
Never More....
 */
class InitModule :BaseModule {
    var listener:InitView?=null

    fun checkMe(imei:String,c:Context){
        Apis.checkME(imei)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<MEBean>>(c){
                                override fun httpSuccess(t: Response<MEBean>) {
                                    listener?.setMe(t.body())
                                }

                                override fun httpFailed(e: Throwable?) {
//                                    super.httpFailed(e)
                                    val meBean = MEBean()
                                    meBean.code=0
                                    meBean.msg="去登陆"
                                    listener?.setMe(meBean)

                                }

                            })
                }
    }
}